using System;
using System.Threading.Tasks;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
using TencentCloud.Sms.V20210111;
using TencentCloud.Sms.V20210111.Models;

namespace lhservice.common
{
  class SmsHelper
  {

    /// <summary>
    /// 
    /// </summary>
    /// <param name="to">
    /// 接收短信的手机号,多个号码以半角逗号分割：1380000000,1380000001
    /// </param>
    /// <param name="tempId">消息模板ＩＤ</param>
    /// <param name="paramLis">
    /// 消息参数，多参数以半角逗号分割：100,60,14
    /// </param>
    /// <returns></returns>

    public static dynamic Send(string to,string tempId,string paramLis)
    {   
      Credential cred = new Credential
      {
        SecretId = "AKIDymLfqseCXceQwB9qGQJvFJQHrACxRebG",
        SecretKey = "QZS4PSEjywd3C4fz3qLdfQt51h9J1Xnn"
      };

      ClientProfile clientProfile = new ClientProfile();
      HttpProfile httpProfile = new HttpProfile();
      httpProfile.Endpoint = ("sms.tencentcloudapi.com");
      clientProfile.HttpProfile = httpProfile;

      SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
      SendSmsRequest req = new SendSmsRequest();
      req.PhoneNumberSet = to.Split(",");
      req.SmsSdkAppId = "1400671884";
      req.SignName = "蓝华软件";
      req.TemplateId = tempId;
      req.TemplateParamSet = paramLis.Split(",");
      SendSmsResponse resp = client.SendSmsSync(req);
      return AbstractModel.ToJsonString(resp);
    }
  }
}
